<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: taohj
  Date: 2014/6/29
  Time: 18:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<c:set var="dashboardMenuTag" value="mydataset" scope="request"></c:set>
<c:set var="menu" value="none" scope="request"></c:set>
<!Doctype html>
<html>
<head>
    <base href="<%=basePath%>">
    <title>政府数据开放平台</title>
    <jsp:include page="../../../commons/include.jsp"/>

    <link href="/resources/css/lib.css" rel="stylesheet">

    <script type="text/javascript">
        $(function () {
            $('.pagination > li').each(function () {
                $(this).on('click', function () {
                    location.href = '/front/my/dataset/data/list?page=' + $(this).attr('page') + '&dataset=' + $('input[name=dataset]').val();
                })
            });

            $("tbody>tr").each(function () {
                var id = $(this).attr('dataid');
                console.info($(this).find('td:last>a:first'));
                $(this).find('td:last>ul>li:first').next().on('click', function () {
                    location.href = '/front/my/dataset/data/modifyV?id=' + id;
                })

                $(this).find('td:last>ul>li:last').on('click', function () {
                    if (confirm("确定要删除吗？")) {
                        location.href = '/front/my/dataset/data/remove?id=' + id;
                    }
                })
            });


            $("form select").on('change', function () {
                $("form").submit();
            });
        });
    </script>

</head>
<body>
<jsp:include page="../../../commons/top.jsp"/>

<div class="main">


    <jsp:include page="../../../commons/dashboardMenu.jsp"/>


    <div class="left">
        <ul>
            <li href="/front/my/dataset/list">数据集管理</li>
            <li href="/front/my/dataset/data/list" class="active">数据管理</li>
        </ul>
    </div>

    <div class="right">
        <div style="padding: 20px;">
            <input name="dataset" type="hidden" value="${result.pageResult.t.dataset.id}">
            <input type="button" value="新增"
                   onclick="location.href='/front/my/dataset/data/createV?dataset=${result.pageResult.t.dataset.id}'">
        </div>


        <div>
            <form action="/front/my/dataset/data/list" style="padding-left: 30px">
                <input type="hidden" name="page">
                <table width="100%">
                    <tr>
                        <td width="10"></td>
                        <td width="80">标题：</td>
                        <td><input type="text" name="title"
                                   value="${requestScope.result.pageResult.t.title}"></td>
                        <td width="10"></td>
                        <td>数据集：</td>
                        <td>
                            <select name="dataset">
                                <option value="">请选择</option>
                                <c:forEach items="${datasets}" var="dataset">
                                    <option value="${dataset.id}"
                                            <c:if test="${dataset.id==requestScope.result.pageResult.t.dataset.id}">selected="selected" </c:if> >${dataset.name}</option>
                                </c:forEach>
                            </select>
                        </td>

                        <td></td>
                    </tr>
                    <tr>
                        <td width="10"></td>
                        <td>是否公开：</td>
                        <td>
                            <select name="visibility" dataSync='true' syncType='dictionary' dictionaryType="VISIBILITY"
                                    selectValue="${requestScope.result.pageResult.t.visibility.id}"
                                    >
                                <option value="">请选择</option>
                            </select>
                        </td>

                        <td width="10"></td>


                        <td>排序：</td>
                        <td><select name="order" style="font-size: 14px;">
                            <option value="">请选择</option>
                            <option value="asc"
                                    <c:if test="${requestScope.result.pageResult.sortBy=='asc'}">selected="selected" </c:if>>
                                名称升序
                            </option>
                            <option value="desc"
                                    <c:if test="${requestScope.result.pageResult.sortBy=='desc'}">selected="selected" </c:if> >
                                名称降序
                            </option>
                        </select></td>

                        <td colspan="1" align="right"><input type="submit" value="搜索"></td>


                    </tr>
                </table>

            </form>

        </div>


        <div style="padding: 10px 20px">
            <span style="font-size: 16px;font-weight: bold">共找到条${requestScope.result.pageResult.total}记录</span>
        </div>


        <div style="padding-left: 10px;padding-top:10px;min-height: 400px;">
            <table class="table">
                <thead>
                <tr style="text-align: left">
                    <td style="width: 40px">序号</td>
                    <td style="width: 150px">标题</td>
                    <td style="width: 100px">标签</td>

                    <td style="width: 100px">机构</td>
                    <td style="width: 80px">存储形式</td>

                    <td style="width: 80px">是否公开</td>
                    <td style="width: 160px">数据集</td>
                    <td style="width: 100px">操作</td>
                </tr>
                </thead>

                <tbody>
                <c:forEach items="${requestScope.result.pageResult.rows}" var="data" varStatus="status">
                    <tr dataid="${data.id}">
                        <td>${status.count+(requestScope.result.pageResult.page-1)*requestScope.result.pageResult.size}</td>
                        <td>${data.title}</td>
                        <td>${data.tags}</td>

                        <td>${data.org.name}</td>
                        <td>${data.storage.name}</td>
                        <td>${data.visibility.name}</td>
                        <td>${data.dataset.name}</td>
                        <td>
                            <ul id="icons" class="ui-widget ui-helper-clearfix">

                                <li class="ui-state-default ui-corner-all" title="预览" onclick="window.open('${data.preview}')"><span
                                        class="ui-icon ui-icon-mail-open"></span></li>
                                <li class="ui-state-default ui-corner-all" title="更新"><span
                                        class="ui-icon ui-icon-pencil"></span></li>
                                <li class="ui-state-default ui-corner-all" title="删除"><span
                                        class="ui-icon ui-icon-trash"></span></li>
                            </ul>
                        </td>
                    </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>


        <div>
            <ul class="pagination" style="margin: 20px 30px;">
                <li page="${requestScope.result.pageResult.startPage-1}">&laquo;</li>

                <c:forEach begin="${requestScope.result.pageResult.startPage}"
                           end="${requestScope.result.pageResult.endPage}" var="index">
                    <li page="${index}" <c:if
                            test="${index==requestScope.result.pageResult.page}"> class="active" </c:if> >${index}
                    </li>
                </c:forEach>

                <li page="${requestScope.result.pageResult.endPage+1}">&raquo;</li>
            </ul>

        </div>

    </div>


</div>

</body>
</html>
